#include <cstdint>
#include <iostream>
#include <istream>
#include <set>
using ll = int64_t;
#define sl static inline

const ll maxn = 1e5+5;
ll T,n,h[maxn];
std::set<ll> s;

sl void solve(){
    std::cin>>n;
    for(ll i=1;i<=n;i++)std::cin>>h[i];
    s.clear();
    for(ll i=2;i<=n;i++){
        if(h[i-1]==h[i] && s.find(h[i])==s.end()){
            s.insert(h[i]);
        }
    }
    for(ll i=3;i<=n;i++){
        if(h[i]==h[i-2] && s.find(h[i])==s.end()){
            s.insert(h[i]);
        }
    }
    if(s.empty()){
        std::cout<<"-1\n";
        return;
    }
    for(const ll i:s){
        std::cout<<i<<" ";
    }
    std::cout<<"\n";
}

int main(){
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cin>>T;
    while(T--)solve();
}